package com.red.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ExitServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        Cookie[] cookies = req.getCookies();
//
//        for (int i = 0; i < cookies.length; i++) {
//            Cookie cookie = cookies[i];
//            if(cookie.getName().equals("userInfo")){
//                cookie.setMaxAge(0);
//                resp.addCookie(cookie);
//                break;
//            }
//        }
        req.getSession().removeAttribute("user");
        req.getRequestDispatcher("index.jsp").forward(req,resp);
    }
}
